import request from '@/config/axios'

export interface MenuVO {
  id?: number
  name: string
  type: string
  parentId: number
  permission: string
  path: string
  icon: string
  component: string
  componentName: string
  visible: boolean
  keepAlive: boolean
  alwaysShow: boolean
  status: number
  sort: number
  createTime?: string
}

export const getMenuSimpleList = async (status?: number) => {
  return await request.get({ url: '/system/menu/simple-list', params: { status } })
}

export const getMenuList = async (params: any) => {
  return await request.get({ url: '/system/menu/list', params })
}

export const getMenu = async (id: number) => {
  return await request.get({ url: '/system/menu/get', params: { id } })
}

export const createMenu = async (data: MenuVO) => {
  return await request.post({ url: '/system/menu/create', data: data })
}

export const updateMenu = async (data: MenuVO) => {
  return await request.post({ url: '/system/menu/update', data: data })
}

export const deleteMenu = async (id: number) => {
  return await request.delete({ url: '/system/menu/delete', params: { id } })
}

export const updateMenuStatus = async (id: number, status: number) => {
  return await request.post({ url: '/system/menu/update_status', data: { id, status } })
}
